#include<bits/stdc++.h>

using namespace std;
int d[100005]={};
int v[100005]={};
int a[100005]={};
int p[100005]={};
bool s[100005]={};
int er[100005]={};

int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int i,j,t,car,mec,road,speedlimit,speedp,ans=0,temp=0,temp1,temp2,weians=1;
    cin>>t;
    t=t+1;
    while(t--)
    {
        if(t==0)
        {
            return 0;
        }

        cin>>car>>mec>>road>>speedlimit;
        for(i=1;i<=car;i++)
        {
            cin>>d[i];
            cin>>v[i];
            cin>>a[i];
        }
        for(i=1;i<=mec;i++)
        {
            cin>>p[i];
        }
        for(i=1;i<=car;i++)
        {
            for(j=1;j<=mec;j++)
            {
                if(d[i]>p[j])
                {
                    continue;
                }
                else
                {
                    speedp=v[i]+a[i]*(p[j]-d[i]);
                    if(speedp<=0)
                    {
                        i+=1;
                        j=1;
                    }
                    else if(speedp>speedlimit)
                    {
                        s[i]=1;
                        er[j]++;
                    }
                    else
                    {
                        continue;
                    }
                }
            }
            if(s[i]==1)
            {
                ans++;
            }
        }
        if(ans==1)
        {
            temp=mec-1;
        }
        else if(mec==1)
        {
            temp=1;
        }
        else
        {
            for(i=1;i<=car;i++)
            {
                if(er[i]==1)
                {

                    weians++;
                }
            }
            temp=mec-weians;
        }

        cout<<ans<<" "<<temp<<endl;
    }
    return 0;

}
